package com.wind.bdg.middlewarelearndemo;

import com.wind.bdg.middlewarelearndemo.service.KafkaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.stereotype.Component;

@Component
public class ServiceDisposableBean implements DisposableBean, ExitCodeGenerator {
    private static Logger LOGGER = LoggerFactory.getLogger(ServiceDisposableBean.class);
    @Autowired
    private KafkaService kafkaService;

    @Override
    public void destroy() throws Exception {
        LOGGER.info("开始销毁资源..");
        kafkaService.reqClose();
    }

    @Override
    public int getExitCode() {

        return 5;
    }
}
